# -- coding: utf-8 --
from tools.Request_General import BaseAPI


class DeepPipeline(BaseAPI):
    """
    数据流相关接口
    """

    def save(self, payload, param):
        """保存流程"""
        r = self.request_send(json=payload, params=param)
        return r

    def published(self, payload):
        """发布流程"""
        r = self.request_send(json=payload)
        return r

    def run(self, payload):
        """运行流程"""
        r = self.request_send(json=payload)
        return r

    def run_history_list(self, payload):
        """执行历史查询"""
        r = self.request_send(json=payload)
        return r

    def copy_element(self, payload):
        """元素复制后置"""
        r = self.request_send(json=payload)
        return r

    def delete_element(self, payload):
        """删除后置"""
        r = self.request_send(json=payload)
        return r

    def export_element(self, payload):
        """元素导出"""
        r = self.request_send(json=payload)
        return r

    def import_element(self, payload):
        """元素导入"""
        r = self.request_send(json=payload)
        return r

    def move_element(self, payload):
        """元素移动后置"""
        r = self.request_send(json=payload)
        return r

    def rename_element(self, payload):
        """元素重命名"""
        r = self.request_send(json=payload)
        return r

    def query_info(self, payload):
        """查询流程"""
        r = self.request_send(json=payload)
        return r

    def read_schema(self, payload):
        """读取数据库下的模式"""
        r = self.request_send(json=payload)
        return r

    def read_table(self, payload):
        """读取该数据库下所有表"""
        r = self.request_send(json=payload)
        return r

    def get_data_source_by_driverId(self, params):
        """根据驱动ID获取数据源信息"""
        r = self.request_send(params=params)
        return r

    def query_history_info(self, payload):
        """查询历史数据"""
        r = self.request_send(json=payload)
        return r

    def switch_history_info(self, params):
        """切到历史版本"""
        r = self.request_send(params=params)
        return r

    def update_version_name(self, params):
        """版本名称编辑"""
        r = self.request_send(params=params)
        return r

    def list_control(self, payload):
        """查询控件列表"""
        r = self.request_send(json=payload)
        return r

    def connection(self, payload):
        """数据库测试连接"""
        r = self.request_send(json=payload)
        return r

    def read_field(self, payload):
        """获得表字段信息"""
        r = self.request_send(json=payload)
        return r

    def run_log_download(self,uri):
        """日志下载"""
        r = self.request_send(uri=uri)
        return r

    def run_rate(self, uri):
        """执行进度查询"""
        r = self.request_send(uri=uri)
        return r


if __name__ == '__main__':
    from application.general_create import COOKIE, APP_ID, SPACE_ID
    import pprint

    headers = {"cookie": COOKIE, "language": "zh-cn", "app": APP_ID, "space": SPACE_ID}
    pprint.pprint(headers)
    r = DeepPipeline(version="1.0", headers=headers).save(
        {
            "baseInfo": {
                "elementName": "test_none6",
                "description": {
                    "zh-cn": "test_none6"
                },
                "folderId": "0"
            },
            "datasources": [],
            "publicDsUUID": [],
            "edges": [],
            "nodes": [],
            "elementSnowflakeId": ""
        }, {"isEdit": False})
    pprint.pprint(r.json())
